Fix compatibility with Rust nightly
authorAlex Crichton <alex@alexcrichton.com>
Wed, 14 Dec 2016 01:18:32 +0000 (17:18 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 14 Dec 2016 01:18:32 +0000 (17:18 -0800)
These two tests actually shouldn't have ever passed, but nightly Rust is more
principled about "$OUT_DIR" and doesn't leak it where possible, so these two
tests were accidentally compiling due to leaking '$OUT_DIR' for Cargo itself.

.travis.yml
tests/build-script.rs

index db5a623335e905f0c9bbf832acfaf55aedf87ba9..ed4d0e289bf4f85eaaa83a90cd098c4256fe5835 100644 (file)
@@ -90,7 +90,7 @@ matrix:
            IMAGE=dist
            MAKE_TARGETS="test distcheck doc install uninstall"
            DEPLOY=0
-      rust: nightly-2016-11-26
+      rust: nightly
 
   exclude:
     - rust: stable
index 01ea55f9a51e32686e76c2b2a6de01091d314318..a96d03ae6b485254cdd49dada5e599a3cdaa5c6e 100644 (file)
@@ -2345,25 +2345,15 @@ fn assume_build_script_when_build_rs_present() {
             authors = []
         "#)
         .file("src/main.rs", r#"
-            use std::path::Path;
             fn main() {
-                let f = env!("OUT_DIR");
-                assert!(
-                    ! Path::new(f).join("output").exists()
-                );
+                if cfg!(foo) {
+                    panic!("the build script was run");
+                }
             }
         "#)
         .file("build.rs", r#"
-            use std::env;
-            use std::fs::File;
-            use std::io::Write;
-            use std::path::Path;
-
             fn main() {
-                let out_dir = env::var_os("OUT_DIR").unwrap();
-                let out_dir = Path::new(&out_dir).join("output");
-                let mut f = File::create(&out_dir).unwrap();
-                f.write_all(b"foo").unwrap();
+                println!("cargo:rustc-cfg=foo");
             }
         "#);
     p.build();
@@ -2390,25 +2380,15 @@ fn if_build_set_to_false_dont_treat_build_rs_as_build_script() {
             build = false
         "#)
         .file("src/main.rs", r#"
-            use std::path::Path;
             fn main() {
-                let f = env!("OUT_DIR");
-                assert!(
-                    ! Path::new(f).join("output").exists()
-                )
+                if cfg!(foo) {
+                    panic!("the build script was run");
+                }
             }
         "#)
         .file("build.rs", r#"
-            use std::env;
-            use std::fs::File;
-            use std::io::Write;
-            use std::path::Path;
-
             fn main() {
-                let out_dir = env::var_os("OUT_DIR").unwrap();
-                let out_dir = Path::new(&out_dir).join("output");
-                let mut f = File::create(&out_dir).unwrap();
-                f.write_all(b"foo").unwrap();
+                println!("cargo:rustc-cfg=foo");
             }
         "#);
     p.build();